

function updateSalesprice()
{
	var checkboxNo = document.getElementsByName("salelist");
	var delrow = document.getElementById("delrow");
	var j = 0;
	
	for(var i = checkboxNo.length - 1; i >= 0; i = i - 1)
	{
		if(checkboxNo[i].checked)
		{
			j = j + 1;
		}
	}
	if(j < 1)
	{
		alert("没有选中要更新的记录！");
	}
	else if(j > 1)
	{
		alert("一次只能更新一条记录！");
	}
	else
	{
		delrow.action = "editSalesprice!editSalesprice.action";
		delrow.submit();
	}
	
}

function selectSalespricepolicy(){
	var checkboxNo = document.getElementsByName("rowlist");
	var delrow = document.getElementById("delrow");
	
	var j = 0;
	for(var i = checkboxNo.length - 1; i >= 0; i = i - 1)
	{
		if(checkboxNo[i].checked)
		{
			j = j + 1;
		}
	}
	if(j < 1)
	{
		alert("请选择一条销售价格政策！");
	}
	else if(j > 1)
	{
		alert("只能选择一条销售价格政策！");
	}
	else
	{
		delrow.action = "showSalespriceList!showSalespriceList.action";
		delrow.submit();
	}
}


var status = false;
function selectAllByClient() {
	var a = document.getElementById("client").getElementsByTagName("input");
	if (status == false) {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = true;
			}
		}
		status = true;
	} else {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = false;
			}
		}
		status = false;
	}
}

function selectAllByMaterial() {
	var a = document.getElementById("material").getElementsByTagName("input");
	if (status == false) {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = true;
			}
		}
		status = true;
	} else {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = false;
			}
		}
		status = false;
	}
}



//审核功能js函数
//本函数只能进行单行审核
function auditingSalesprice(action, method) {
	var checkboxNo = document.getElementsByName("salelist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//form的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num <1) {
		alert("您还没有进行选择！");
	} else if (num > 1) {
			alert("每次只能审核一条记录！");
		} else 	if (num == 1) {
				if (confirm("确认要审核该记录吗？")) {
					delrow.action = action + "!" + method + ".action";
			//提交表单到action	
					delrow.submit();
		}
	}
}

//反审核功能js函数
//本函数只可以进行单行反审核
function reAuditingSalesprice(action, method) {
	var checkboxNo = document.getElementsByName("salelist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//form的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num <1) {
		alert("您还没有进行选择！");
	} else if (num > 1) {
			alert("每次只能反审核一条记录！");
		} else 	if (num == 1) {
				if (confirm("确认要反审核该记录吗？")) {
					delrow.action = action + "!" + method + ".action";
			//提交表单到action	
					delrow.submit();
		}
	}
}

function controlPrice(action, method)
{
var checkboxNo = document.getElementsByName("salelist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//form的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num <1) {
		alert("您还没有进行选择！");
	} else if (num > 1) {
			alert("每次只能选择一条记录！");
		} else 	if (num == 1) {
				if (confirm("确认要进行限价吗？")) {
					delrow.action = action + "!" + method + ".action";
			//提交表单到action	
					delrow.submit();
		}
	}
}


//删除按钮
function delSalesprice(action, method) {
	var checkboxNo = document.getElementsByName("salelist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//formd的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}

	if (num <1) {
		alert("您还没有进行选择！");
	} else if (num > 1) {
			alert("每次只能选择一条记录！");
		} else 	if (num == 1) {
				if (confirm("确认要删除选中的记录吗？")) {
					delrow.action = action + "!" + method + ".action";
			//提交表单到action	
					delrow.submit();
		}
	}
}

//
//function Equalt(datestr1, datestr2){
  //  tmpBeginTime = new Date(datestr1.replace(/-/g,"\/"));
  //  tmpEndTime = new Date(datestr2.replace(/-/g,"\/"));
   // if ( tmpBeginTime > tmpEndTime ){
   //     alert ("起始时间大于结束时间");
    //}else if( tmpBeginTime < tmpEndTime ){
     //   alert ("起始时间小于结束时间")
    //}else{
   //     alert("起始时间与结束时间相等")
    //}
//}

//周期设置
function interzone(obja,objb,code){

	var a = obja.value;
	var b = objb.value;
	
	tmpBeginTime = new Date(a.replace(/-/g,"\/"));
    tmpEndTime = new Date(b.replace(/-/g,"\/"));
    
	
	if(tmpBeginTime > tmpEndTime){
		f_alert(code,"错误的周期，后者时间的必须晚于前者");
		return false;
	}else{
		
		return true;
		
	}
}

function compareint(from,to,code){
	var a = from.value;
	var b = to.value;
	var aa = parseInt(a);
	var bb = parseInt(b);
	if(aa<bb){
		return true;
	}else{
		f_alert(code,"错误的销量量区间")
		return false;
	}
}

function comparemoney(bid,topbid,code){
	var x = bid.value;
	var y = topbid.value;
	var xx = parseFloat(x);
	var yy = parseFloat(y);
	if(xx<yy){
		return true;
	}else{
		f_alert(code,"最低报价必须小于报价")
		return false;
	}
}

//修改按钮
function updateSalesprice(action, method) {
	var checkboxNo = document.getElementsByName("salelist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//formd的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num <1) {
		alert("您还没有进行选择！");
	} else if (num > 1) {
			alert("每次修改只能选择一条记录！");
		} else 	if (num == 1) {
				if (confirm("确认要修改该记录吗？")) {
					delrow.action = action + "!" + method + ".action";
			//提交表单到action	
					delrow.submit();
		}
	}
}
